<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include/src :: form_base_js_and_css"/>
</head>
<body style="background-color: #f2f2f2; height: 100%;">

	<div id="id_panel">
	</div>
	<input type="hidden" name="boutiqueSiteDetailId" id="boutiqueSiteDetailId" value=""><!--id-->
	<script th:inline="javascript">
		$('#boutiqueSiteDetailId').val('[(${idInfo.id})]');
		var aplusCount = '[(${idInfo.aplusCount})]';
		var fileCount = '[(${idInfo.fileCount})]';
		/*
		var picList = ['mainPic1','mainPic2','mainPic3','mainPic4','mainPic5',//主图
			'sizePic1','sizePic2','sizePic3',//尺寸图
			'scenePic1','scenePic2','scenePic3','scenePic4','scenePic5','scenePic6',//场景图
			'detailsPic1','detailsPic2','detailsPic3',//细节图
			'usePic1','usePic2','usePic3','usePic4'//应用图
		];
		 */
		var picList = ['mainPic1','mainPic2','mainPic3',//主图
			'sizePic1',//尺寸图
			'scenePic1','scenePic2',//场景图
			'detailsPic1',//细节图
			'usePic1','usePic2',
			'mainPic4','mainPic5','sizePic2','sizePic3','scenePic3','scenePic4','scenePic5','scenePic6','detailsPic2','detailsPic3','usePic3','usePic4'//应用图
		];
		var picIndex = 0;


	// 表单初始化
	var formObj = null;
	//使用layui的sku模块
	layui.config({
	    //自定义layui组件的目录,设定扩展的layui模块的所在目录，一般用于外部模块扩展
	    base: '/static/js/layui_extends/',
		version: true
	}).use(['form', 'jquery', 'laydate', 'YsForm', 'YsModal'], function(){
		var $ = layui.jquery,
		form = layui.form,
				laydate = layui.laydate,
				YsForm = layui.YsForm,
				YsModal = layui.YsModal
		/* 
		* 表单初始化
		* 参数1：表单配置参数
		* 参数2：子表配置参数
		*/
		formObj = YsForm.init(
		{
			id:'id_panel', // 页面容器ID
			dto: $.parseJSON(JSON.stringify([[${dto}]]))
		}
		);

		//附件按钮
		var fileHtml = ``
				+ `<div class="layui-inline layui-col-xs4 margin_r_0">`
				+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">附件：</label>`
				+ `<div class="layui-input-block margin_l_150 min_height_38" style="padding-bottom: 120px;">`
				+ `<button type="button" class="layui-btn layui-btn-primary" onclick="fileManage()">`+([[${onProcess}]]=="1"?`点击查看附件`:`点击上传附件`)+`<span id="fileCount">(`+fileCount+`个附件)</span></button>`
				+ `</div>`
				+ `</div>`;
		$('#' + formObj.c.id_form).find('.layui-form-item').append(fileHtml);

		//A+附件按钮
		var str = ``
			+ `<div class="layui-inline layui-col-xs4 margin_r_0">`
			+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">A+附件：</label>`
			+ `<div class="layui-input-block margin_l_150 min_height_38" style="padding-bottom: 120px;">`
			+ `<button type="button" class="layui-btn layui-btn-primary" onclick="aplusFileManage()">`+([[${onProcess}]]=="1"?`点击查看A+附件`:`点击上传A+附件`)+`<span id="aPlusCount">(`+aplusCount+`个附件)</span></button>`
			+ `</div>`
			+ `</div>`;
		$('#' + formObj.c.id_form).find('.layui-form-item').append(str);
		//图片批量上传按钮
		$('#' + formObj.c.id_header).find('.bg_color_white').find('.layui-inline').append('<button type="button" class="layui-btn layui-btn-normal" id="uploadPicList" lay-submit onclick="uploadFilses()">批量导入图片</button>');
		//图片批量上传
		layui.upload.render({
			elem: '#uploadPicList',
			url: 'https://file.mini-ease.com/api/outer/upload/uploadForERP_1_0',
			accept: 'images',
			multiple: true,
			done: function(res){
				// 上传完毕
				console.log("上传返回：",res);
				formObj.setValueByName(picList[picIndex],res.data.filePath);
				$('#' + formObj.c.id_form).find('img[label="' + picList[picIndex]+ '"]').attr('src', res.data.filePath);
				picIndex ++;
			}
		});
		//批量维护商品数据
		//$('#' + formObj.c.id_header).find('.bg_color_white').find('.layui-inline')
				//.append('<button type="button" class="layui-btn layui-btn-normal" id="uploadInfoList" lay-submit onclick="uploadInfoList()">批量维护商品数据</button>');
		if([[${onProcess}]]=='1'){
			//隐藏头部按钮
			$('#' + formObj.c.id_header).hide();
		}


	});

	</script>

	<script type="text/javascript">

		function uploadFilses() {
			picIndex = 0;
		}

		//附件页面
		function fileManage() {
			var w=($(window).width()*0.7);
			//var h=($(window).height() - 350);
			var h=($(window).height() - 50);
			var index = layer.open({
				type: 2,
				area: [w+'px', h +'px'],
				fix: true,
				maxmin: false,
				shadeClose: true,
				shade:0.4,
				title: "附件",
				content: '/web/business/tpBoutiqueSiteDetail/siteFileManage?id='+$('#boutiqueSiteDetailId').val()+'&onProcess='+[[${onProcess}]]
			});
		}

		//A+附件页面
		function aplusFileManage() {
			var w=($(window).width()*0.7);
			//var h=($(window).height() - 350);
			var h=($(window).height() - 50);
			var index = layer.open({
				type: 2,
				area: [w+'px', h +'px'],
				fix: true,
				maxmin: false,
				shadeClose: true,
				shade:0.4,
				title: "A+管理",
				content: '/web/business/tpBoutiqueSiteDetail/aplusFileManage?id='+$('#boutiqueSiteDetailId').val()+'&onProcess='+[[${onProcess}]]
			});
		}


		/*

		function uploadInfoList () {
			var w=($(window).width()*0.7);
			var h=($(window).height() - 50);
			var index = layer.open({
				type: 2,
				area: [w+'px', h +'px'],
				fix: true,
				maxmin: false,
				shadeClose: true,
				shade:0.4,
				title: "批量维护商品数据",
				content: '/web/business/tpBoutiqueSiteDetail/importDetailList?id=5'
			});
		}

		 */


	</script>
</body>
</html>
